/*package com.nuanshui.heatedloan.config;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletException;
import javax.servlet.FilterRegistration.Dynamic;
import javax.servlet.ServletContext;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.io.support.ResourcePropertySource;
import org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import org.springframework.web.util.IntrospectorCleanupListener;

import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import com.nuanshui.commonservice.config.CommonConfig;
import com.nuanshui.heatedloan.baseservice.config.BaseServiceConfig;
import com.nuanshui.heatedloan.extension.shiro.SimpleCaptchaServlet;
import com.nuanshui.heatedloan.middleware.config.MiddlewareConfig;

public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{

	
	@Override
	public void onStartup(ServletContext servletContext)
			throws ServletException {
		super.onStartup(servletContext);
		
		//配置一些filter
		
		FilterRegistration.Dynamic openEntityManagerInViewFilter = servletContext.addFilter("openEntityManagerInViewFilter", OpenEntityManagerInViewFilter.class);
		openEntityManagerInViewFilter.addMappingForUrlPatterns(null, false, "/*");
		
		FilterRegistration.Dynamic delegatingFilterProxy = servletContext.addFilter("shiroFilter", DelegatingFilterProxy.class);
		delegatingFilterProxy.setInitParameter("targetFilterLifecycle", "true");
		delegatingFilterProxy.addMappingForUrlPatterns(null, false, "/*");
		
		
		FilterRegistration.Dynamic encodingFilter = servletContext.addFilter("encodingFilter",CharacterEncodingFilter.class);
		encodingFilter.setInitParameter("encoding", "UTF-8");
		encodingFilter.setInitParameter("forceEncoding", "true");
		encodingFilter.addMappingForUrlPatterns(null, false, "/*");
		
		
		FilterRegistration.Dynamic druidWebStatFilter = servletContext.addFilter("druidWebStatFilter",WebStatFilter.class);
		druidWebStatFilter.setInitParameter("exclusions", "/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
		druidWebStatFilter.setInitParameter("principalSessionName", "sessionInfo");
		druidWebStatFilter.setInitParameter("profileEnable", "true");
		druidWebStatFilter.setInitParameter("sessionStatEnable", "true");
		druidWebStatFilter.addMappingForUrlPatterns(null, false, "/*");
		
	}
	
	@Override
	protected Class<?>[] getRootConfigClasses() {
		return new Class<?>[] {RootConfig.class,ShiroConfig.class, MiddlewareConfig.class, CommonConfig.class, ApplicationConfig.class, BaseServiceConfig.class};
	}

	@Override
	protected Class<?>[] getServletConfigClasses() {
		return new Class<?>[] {WebMvcConfig.class};
	}

	@Override
	protected String[] getServletMappings() {
		return new String[] {"/"};
	}
	
	
	@Override
	protected void registerDispatcherServlet(ServletContext servletContext) {
		
		super.registerDispatcherServlet(servletContext);
		
		SimpleCaptchaServlet captchaServlet = new SimpleCaptchaServlet();
		servletContext.addServlet("captchaServlet", captchaServlet).addMapping("/Captcha.jpg");
		
		StatViewServlet druidStatView = new StatViewServlet();
		servletContext.addServlet("druidStatView", druidStatView).addMapping("/cms/manage/druid/*");
		
	}
	
	
	*//**
	 * 配置使用哪一个配置
	 * @author Gonzo
	 * @date 2016年12月28日
	 *//*
	static class ConfigApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

		private Logger LOG = LoggerFactory.getLogger(ConfigApplicationContextInitializer.class);

		@Override
		public void initialize(ConfigurableApplicationContext applicationContext) {
			ConfigurableEnvironment environment = applicationContext.getEnvironment();
			try {
				//加载使用那个配置文件             
				environment.getPropertySources().addFirst(new ResourcePropertySource("classpath:filtered.properties"));
				LOG.error("filtered.properties loaded");
				
			} catch (IOException e) {
				LOG.error("didn't find filtered.properties in classpath so not loading it in the AppContextInitialized");
			}
		}
	}
	
	@Override
	protected void registerContextLoaderListener(ServletContext servletContext) {
		super.registerContextLoaderListener(servletContext);
		
		IntrospectorCleanupListener introspectorCleanupListener = new IntrospectorCleanupListener();
		servletContext.addListener(introspectorCleanupListener);
	}
}
*/